package com.apiserver.data.Exception;

import com.apiserver.kernel.result.StatusCode;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author feizhou
 * @Description 错误码
 * @Date 下午 5:18 2019/1/8 0008
 * @Param
 * @return
 **/
@Getter
public enum ErrCode {


    //实体不能定义多个主键
    PK__multiple(101, "实体不能定义多个主键"),

    //实体类需要table注解
    table_Not_Exist(102, "实体类需要table注解"),;

    private static final Map<Integer, StatusCode> CODE_MAP = new HashMap<Integer, StatusCode>();

    private final Integer code;
    private final String errMess;


    static {
        for (StatusCode typeEnum : StatusCode.values()) {
            CODE_MAP.put(typeEnum.getCode(), typeEnum);
        }
    }

    ErrCode(Integer code, String errMess) {
        this.code = code;
        this.errMess = errMess;
    }


    public static StatusCode getEnum(Integer code) {

        return CODE_MAP.get(code);
    }


}
